<template>
  <div class style="padding: 20px;">
    <!-- <div class="fw p10">
      <div class="fwwcc">
        <div class="block">
          <span class="demonstration m10">请选择时间范围</span>
        </div>
        <el-date-picker
          v-model="value2"
          type="datetimerange"
          :picker-options="pickerOptions"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          align="right"
        ></el-date-picker>
      </div>
      <div class="p10">
        <el-button type="primary" @click="1">查询</el-button>
      </div>
    
    </div> -->
    <div class="p10">
      <el-table :data="tableData" style="width: 100%">
        <el-table-column prop="module" label="模块" width=""></el-table-column>
        <el-table-column prop="userCode" label="用户名" width=""></el-table-column>
        <el-table-column prop="userIP" label="IP"></el-table-column>
        <el-table-column prop="createTime" label="时间"></el-table-column>
      </el-table>
    </div>
    <div class="fwwcc p10">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="current"
        :page-sizes="[5, 10, 20, 50]"
        :page-size="size"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      ></el-pagination>
    </div>
  </div>
</template>
<script>

import logService from '@/api/logService'

export default {
  components: {},
  data() {
    return {
      pickerOptions: {
        shortcuts: [
          {
            text: "最近一周",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit("pick", [start, end]);
            }
          },
          {
            text: "最近一个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
              picker.$emit("pick", [start, end]);
            }
          },
          {
            text: "最近三个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
              picker.$emit("pick", [start, end]);
            }
          }
        ]
      },
      value2: "",
      size: 5,
      total: 0,
      current: 1,
      tableData: [
        {
          date: "2020-01-02",
          name: "告警",
          address: "系统cpu使用率过高"
        },
        {
          date: "2020-01-04",
          name: "错误",
          address: "系统启动参数异常"
        },
        {
          date: "2020-01-01",
          name: "异常",
          address: "admin管理员错误登录次数过多"
        },
        {
          date: "2020-01-03",
          name: "正常",
          address: "管理员登录"
        }
      ]
    };
  },
  computed: {},
  watch: {},
  mounted() {
    this.initdata()
  },
  methods: {
    initdata(){
      
      logService.syslogList({current: this.current,size: this.size}).then(res => {
        this.tableData = res.data.records
        this.total = res.data.total
      })
    },
    handleSizeChange(val) {
      this.size = val
      this.initdata()
    },
    handleCurrentChange(val) {
      this.current = val
      this.initdata()
    }
  }
};
</script>
<style lang='scss' scoped>
</style>